define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'caiwu/money/index' + location.search,
                    add_url: 'caiwu/money/add',
                    edit_url: 'caiwu/money/edit',
                    del_url: 'caiwu/money/del',
                    multi_url: 'caiwu/money/multi',
                    import_url: 'caiwu/money/import',
                    table: 'admin_money',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                showToggle: false, // 浏览模式切换
                showColumns: true, // 允许选择显示字段
                showExport: true, // 导出选项
                exportDataType: "basic", //导出当前页
                exportTypes: ['excel'],
                searchFormVisible: false, // 通用搜索 默认是否显示
                search: false, // 是否关闭搜索
                trimOnSearch: true, // 自动删除搜索空格
                pageList: [10, 20, 30, 50],
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [{
                            checkbox: true
                        },
                        {
                            field: 'id',
                            title: __('Id')
                        },
                        {
                            field: 'admin_id',
                            title: __('Admin_id')
                        },
                        {
                            field: 'money',
                            title: __('Money'),
                            operate: 'BETWEEN'
                        },
                        {
                            field: 'before',
                            title: __('Before'),
                            operate: 'BETWEEN'
                        },
                        {
                            field: 'after',
                            title: __('After'),
                            operate: 'BETWEEN'
                        },
                        {
                            field: 'memo',
                            title: __('Memo'),
                            operate: 'LIKE',
                            table: table,
                            class: 'autocontent',
                            formatter: Table.api.formatter.content
                        },
                        {
                            field: 'createtime',
                            title: __('Createtime'),
                            operate: 'RANGE',
                            addclass: 'datetimerange',
                            autocomplete: false,
                            formatter: Table.api.formatter.datetime
                        },
                        {
                            field: 'type',
                            title: __('Type'),
                            searchList: {
                                "1": __('Type 1'),
                                "2": __('Type 2'),
                                "3": __('Type 3'),
                                "4": __('Type 4'),
                                "5": __('Type 5'),
                                "6": __('余额提现'),
                            },
                            formatter: Table.api.formatter.normal
                        },
                        {
                            field: 'orderPc',
                            title: __('Orderpc'),
                            operate: '=',
                            table: table,
                            class: 'autocontent',
                            formatter: Table.api.formatter.content
                        },
                        {
                            field: 'type1',
                            title: __('Type1'),
                            searchList: {
                                "1": __('Type1 1'),
                                "2": __('Type1 2')
                            },
                            formatter: Table.api.formatter.normal
                        },
                        {
                            field: 'operate',
                            title: __('Operate'),
                            table: table,
                            events: Table.api.events.operate,
                            formatter: Table.api.formatter.operate
                        }
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});